package com.linsen.uaa.provider.enums;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * 登录方式
 */
@Getter
@AllArgsConstructor
public enum LoginAccountType {
    PASSWORD("password","账户密码"),
    MOBILE("mobile","手机短信"),
    ;

    @JsonValue
    private String value;
    private String description;

    private static final Map<String, LoginAccountType> VALUES = new HashMap<>();

    static {
        for (final LoginAccountType loginAccountType : LoginAccountType.values()) {
            LoginAccountType.VALUES.put(loginAccountType.getValue(), loginAccountType);
        }
    }

    @JsonCreator
    public static LoginAccountType getByValue(String value) {
        return LoginAccountType.VALUES.get(value);
    }
}
